#include "stdio.h"
#include "unicodeToGB2312.h"

u8 Zn[] = "北京大学";

u16 UnicodeTemp[10];
u8 Buf[20];

void main(void)
{
	u16 *pZn;
	u16 unicode_temp;
	pZn = (u16 *)Zn;
	u8 i = 0;

	u8 utf8data[] = "企鹅";
	unsigned long unicode[16] = {0};
	u16 gb2312data[16] = {0};

	printf("utf-8: ");
	for (i = 0; i < sizeof(utf8data) - 1; i++)
	{
		printf("%02X ",utf8data[i]);
	}
	printf("\n");
	printf("unicode: ");
	for (i = 0; i < sizeof(utf8data) / 3; i++)//utf-8转unicode
	{
		enc_utf8_to_unicode_one(&utf8data[i * 3], &unicode[i]);
		printf("%08x ",unicode[i]);
	}
	printf("\n");
	printf("gb2312: ");
	for (i = 0; i < sizeof(utf8data) / 3; i++)
	{
		gb2312data[i] = UnicodeToGB2312((u16)unicode[i]);
		printf("%04x ",gb2312data[i]);
	}
	printf("\n");


	GB2312ToUnicode_Str(UnicodeTemp, "鲁东大学");
	for (i = 0; i < sizeof("鲁东大学") - 1; i++)
	{
		printf("%02X ", UnicodeTemp[i]);
	}
	printf("\n");
	NetworkByteOrder(Buf, UnicodeTemp, sizeof("鲁东大学") - 1);
	for (i = 0; i < sizeof("鲁东大学") - 1; i++)
	{
		printf("%02X ", Buf[i]);
	}
	printf("\n");

	printf("%02X\t%02X\t%02X\t%02X\t", pZn[0], pZn[1], pZn[2], pZn[3]);

	unicode_temp = GB2312ToUnicode(*pZn); //郑的GB2312吗是0xD6A3  unicode是0x90D1
	printf("Unicode:%02X\t\t", unicode_temp);

	unicode_temp = UnicodeToGB2312(unicode_temp);
	printf("GB2312:%02X\n", unicode_temp);
}